@@ -0,0 +1,3 @@  | 
            ||
| 1 | 
                +[submodule "src/brand"]  | 
            |
| 2 | 
                + path = src/brand  | 
            |
| 3 | 
                + url = paiai@git.xfoto.com.cn:SCRM/brand.git  | 
            
                @@ -9,10 +9,10 @@ module.exports = {
               | 
            ||
| 9 | 9 | 
                 | 
            
| 10 | 10 | 
                // Paths  | 
            
| 11 | 11 | 
                assetsSubDirectory: 'static',  | 
            
| 12 | 
                - assetsPublicPath: './',  | 
            |
| 12 | 
                + assetsPublicPath: '/',  | 
            |
| 13 | 13 | 
                     proxyTable: {
               | 
            
| 14 | 14 | 
                       '/api': {
               | 
            
| 15 | 
                - target: 'http://kodo.xfoto.com.cn',//设置你调用的接口域名和端口号  | 
            |
| 15 | 
                + target: 'http://kodo.xfoto.com.cn',  | 
            |
| 16 | 16 | 
                changeOrigin: true //跨域  | 
            
| 17 | 17 | 
                }  | 
            
| 18 | 18 | 
                },  | 
            
                @@ -0,0 +1 @@  | 
            ||
| 1 | 
                +Subproject commit 12962322ad6a6202d5797f67a727fc3e98c28eda  | 
            
                @@ -22,6 +22,7 @@ const SettingSalesmanEditor = r => require.ensure([], () => r(require('../views/
               | 
            ||
| 22 | 22 | 
                 export default [{
               | 
            
| 23 | 23 | 
                path: '/',  | 
            
| 24 | 24 | 
                component: App,  | 
            
| 25 | 
                + mode: 'history',  | 
            |
| 25 | 26 | 
                children: [  | 
            
| 26 | 27 | 
                     {
               | 
            
| 27 | 28 | 
                path: 'login',  | 
            
                @@ -2,91 +2,92 @@  | 
            ||
| 2 | 2 | 
                 | 
            
| 3 | 3 | 
                import axios from 'axios'  | 
            
| 4 | 4 | 
                import qs from 'qs'  | 
            
| 5 | 
                +import brand from '../brand/config.js'  | 
            |
| 5 | 6 | 
                 | 
            
| 6 | 
                -axios.interceptors.request.use(config => {    // 这里的config包含每次请求的内容
               | 
            |
| 7 | 
                - // 判断localStorage中是否存在api_token  | 
            |
| 8 | 
                -    if (localStorage.getItem('api_token')) {
               | 
            |
| 9 | 
                - // 存在将api_token写入 request header  | 
            |
| 10 | 
                -        config.headers.apiToken = `${localStorage.getItem('api_token')}`;
               | 
            |
| 11 | 
                - }  | 
            |
| 12 | 
                - return config;  | 
            |
| 7 | 
                +axios.interceptors.request.use(config => { // 这里的config包含每次请求的内容
               | 
            |
| 8 | 
                + // 判断localStorage中是否存在api_token  | 
            |
| 9 | 
                +  if (localStorage.getItem('api_token')) {
               | 
            |
| 10 | 
                + // 存在将api_token写入 request header  | 
            |
| 11 | 
                +    config.headers.apiToken = `${localStorage.getItem('api_token')}`
               | 
            |
| 12 | 
                + }  | 
            |
| 13 | 
                + return config  | 
            |
| 13 | 14 | 
                 }, err => {
               | 
            
| 14 | 
                - return Promise.reject(err);  | 
            |
| 15 | 
                -});  | 
            |
| 15 | 
                + return Promise.reject(err)  | 
            |
| 16 | 
                +})  | 
            |
| 16 | 17 | 
                 | 
            
| 17 | 18 | 
                 axios.interceptors.response.use(response => {
               | 
            
| 18 | 
                - return response  | 
            |
| 19 | 
                + return response  | 
            |
| 19 | 20 | 
                 }, error => {
               | 
            
| 20 | 
                - return Promise.resolve(error.response)  | 
            |
| 21 | 
                -});  | 
            |
| 21 | 
                + return Promise.resolve(error.response)  | 
            |
| 22 | 
                +})  | 
            |
| 22 | 23 | 
                 | 
            
| 23 | 24 | 
                 function checkStatus (response) {
               | 
            
| 24 | 
                - // 如果http状态码正常,则直接返回数据  | 
            |
| 25 | 
                - if (response && (response.status === 200 || response.status === 304 ||  | 
            |
| 26 | 
                -            response.status === 400)) {
               | 
            |
| 27 | 
                - return response  | 
            |
| 28 | 
                - }  | 
            |
| 29 | 
                - // 异常状态下,把错误信息返回去  | 
            |
| 30 | 
                -    return {
               | 
            |
| 31 | 
                - status: -404,  | 
            |
| 32 | 
                - msg: '网络异常'  | 
            |
| 33 | 
                - }  | 
            |
| 25 | 
                + // 如果http状态码正常,则直接返回数据  | 
            |
| 26 | 
                + if (response && (response.status === 200 || response.status === 304 ||  | 
            |
| 27 | 
                +      response.status === 400)) {
               | 
            |
| 28 | 
                + return response  | 
            |
| 29 | 
                + }  | 
            |
| 30 | 
                + // 异常状态下,把错误信息返回去  | 
            |
| 31 | 
                +  return {
               | 
            |
| 32 | 
                + status: -404,  | 
            |
| 33 | 
                + msg: '网络异常'  | 
            |
| 34 | 
                + }  | 
            |
| 34 | 35 | 
                }  | 
            
| 35 | 36 | 
                 | 
            
| 36 | 37 | 
                 function checkCode (res) {
               | 
            
| 37 | 
                - // 如果code异常(这里已经包括网络错误,服务器错误,后端抛出的错误),可以弹出一个错误提示,告诉用户  | 
            |
| 38 | 
                -    if (res.status === -404) {
               | 
            |
| 39 | 
                - alert(res.msg)  | 
            |
| 40 | 
                - }  | 
            |
| 41 | 
                -    if (res.data && (!res.data.success)) {
               | 
            |
| 42 | 
                - // alert(res.data.error_msg)  | 
            |
| 43 | 
                - }  | 
            |
| 44 | 
                - return res  | 
            |
| 38 | 
                + // 如果code异常(这里已经包括网络错误,服务器错误,后端抛出的错误),可以弹出一个错误提示,告诉用户  | 
            |
| 39 | 
                +  if (res.status === -404) {
               | 
            |
| 40 | 
                + alert(res.msg)  | 
            |
| 41 | 
                + }  | 
            |
| 42 | 
                +  if (res.data && (!res.data.success)) {
               | 
            |
| 43 | 
                + // alert(res.data.error_msg)  | 
            |
| 44 | 
                + }  | 
            |
| 45 | 
                + return res  | 
            |
| 45 | 46 | 
                }  | 
            
| 46 | 47 | 
                // 请求方式的配置  | 
            
| 47 | 48 | 
                 export default {
               | 
            
| 48 | 
                -    post (url, data) {  //  post
               | 
            |
| 49 | 
                -        return axios({
               | 
            |
| 50 | 
                - method: 'post',  | 
            |
| 51 | 
                - baseURL: '',  | 
            |
| 52 | 
                - url,  | 
            |
| 53 | 
                - data: qs.stringify(data),  | 
            |
| 54 | 
                - timeout: 5000,  | 
            |
| 55 | 
                -            headers: {
               | 
            |
| 56 | 
                - "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",  | 
            |
| 57 | 
                - 'Accept': 'application/json'  | 
            |
| 58 | 
                - },  | 
            |
| 59 | 
                - withCredentials : true,  | 
            |
| 60 | 
                - crossDomain: true  | 
            |
| 61 | 
                - }).then(  | 
            |
| 62 | 
                -            (response) => {
               | 
            |
| 63 | 
                - return checkStatus(response)  | 
            |
| 64 | 
                - }  | 
            |
| 65 | 
                - ).then(  | 
            |
| 66 | 
                -            (res) => {
               | 
            |
| 67 | 
                - return checkCode(res)  | 
            |
| 68 | 
                - }  | 
            |
| 69 | 
                - )  | 
            |
| 70 | 
                - },  | 
            |
| 71 | 
                -    get (url, params) {  // get
               | 
            |
| 72 | 
                -        return axios({
               | 
            |
| 73 | 
                - method: 'get',  | 
            |
| 74 | 
                - baseURL: 'http://kodo.xfoto.com.cn/api/',  | 
            |
| 75 | 
                - url,  | 
            |
| 76 | 
                - params, // get 请求时带的参数  | 
            |
| 77 | 
                - timeout: 5000,  | 
            |
| 78 | 
                -            headers: {
               | 
            |
| 79 | 
                - // 'X-Requested-With': 'XMLHttpRequest',  | 
            |
| 80 | 
                - 'Content-Type': 'application/x-www-form-urlencoded'  | 
            |
| 81 | 
                - }  | 
            |
| 82 | 
                - }).then(  | 
            |
| 83 | 
                -            (response) => {
               | 
            |
| 84 | 
                - return checkStatus(response)  | 
            |
| 85 | 
                - }  | 
            |
| 86 | 
                - ).then(  | 
            |
| 87 | 
                -            (res) => {
               | 
            |
| 88 | 
                - return checkCode(res)  | 
            |
| 89 | 
                - }  | 
            |
| 90 | 
                - )  | 
            |
| 91 | 
                - }  | 
            |
| 49 | 
                +  post (url, data) { //  post
               | 
            |
| 50 | 
                +    return axios({
               | 
            |
| 51 | 
                + method: 'post',  | 
            |
| 52 | 
                + baseURL: brand.baseURL,  | 
            |
| 53 | 
                + url,  | 
            |
| 54 | 
                + data: qs.stringify(data),  | 
            |
| 55 | 
                + timeout: 5000,  | 
            |
| 56 | 
                +      headers: {
               | 
            |
| 57 | 
                + 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',  | 
            |
| 58 | 
                + 'Accept': 'application/json'  | 
            |
| 59 | 
                + },  | 
            |
| 60 | 
                + withCredentials: true,  | 
            |
| 61 | 
                + crossDomain: true  | 
            |
| 62 | 
                + }).then(  | 
            |
| 63 | 
                +      (response) => {
               | 
            |
| 64 | 
                + return checkStatus(response)  | 
            |
| 65 | 
                + }  | 
            |
| 66 | 
                + ).then(  | 
            |
| 67 | 
                +      (res) => {
               | 
            |
| 68 | 
                + return checkCode(res)  | 
            |
| 69 | 
                + }  | 
            |
| 70 | 
                + )  | 
            |
| 71 | 
                + },  | 
            |
| 72 | 
                +  get (url, params) { // get
               | 
            |
| 73 | 
                +    return axios({
               | 
            |
| 74 | 
                + method: 'get',  | 
            |
| 75 | 
                + baseURL: brand.baseURL,  | 
            |
| 76 | 
                + url,  | 
            |
| 77 | 
                + params, // get 请求时带的参数  | 
            |
| 78 | 
                + timeout: 5000,  | 
            |
| 79 | 
                +      headers: {
               | 
            |
| 80 | 
                + // 'X-Requested-With': 'XMLHttpRequest',  | 
            |
| 81 | 
                + 'Content-Type': 'application/x-www-form-urlencoded'  | 
            |
| 82 | 
                + }  | 
            |
| 83 | 
                + }).then(  | 
            |
| 84 | 
                +      (response) => {
               | 
            |
| 85 | 
                + return checkStatus(response)  | 
            |
| 86 | 
                + }  | 
            |
| 87 | 
                + ).then(  | 
            |
| 88 | 
                +      (res) => {
               | 
            |
| 89 | 
                + return checkCode(res)  | 
            |
| 90 | 
                + }  | 
            |
| 91 | 
                + )  | 
            |
| 92 | 
                + }  | 
            |
| 92 | 93 | 
                }  |